package com.rzico.sbl.ui.report

import com.rzico.sbl.R
import com.rzico.sbl.databinding.ActivityReportWaterBinding
import com.rzico.sbl.model.WaterShopData
import com.xinnuo.common.extend.oneClick
import com.xinnuo.common.extend.orEmpty
import com.xinnuo.common.extend.startActivityEx
import com.xinnuo.common_ui.base.BaseActivity

class ReportWaterActivity : BaseActivity(R.layout.activity_report_water) {

    private val mBinding by lazy { ActivityReportWaterBinding.bind(getRootView()) }

    private var mWaterData: WaterShopData? = null

    override fun initData() {
        initTitle(title = "水站")

        intent
            .getParcelableExtra<WaterShopData>("data")
            ?.let {
                mWaterData = it
                setData()
            }
    }

    override fun initListener() {
        mBinding.apply {
            waterGoods.oneClick {
                mWaterData?.let {
                    startActivityEx<ReportWaterGoodsActivity>(
                        "shopId" to it.id
                    )
                }
            }

            waterOrder.oneClick {
                mWaterData?.let {
                    startActivityEx<ReportTotalActivity>(
                        "shopId" to it.id
                    )
                }
            }
        }
    }

    private fun setData() {
        mWaterData?.let {
            mBinding.apply {
                waterShop.text = it.name
                waterName.text = it.linkman.orEmpty("无")
                waterPhone.text = it.phone
                waterAdress.text = it.address.orEmpty("暂无地址")
            }
        }
    }

}